import React, { Suspense, useState } from 'react';
import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
import { Button, Layout, theme } from 'antd';
import './home-page.scss';
import MenuSider from '@/components/menu-sider';
import { Outlet } from 'react-router-dom';
import AuthRoute from '@/router/autn-router';

const { Header, Content, Footer } = Layout;

const HomePage: React.FC = () => {
  const [collapsed, setCollapsed] = useState(false);
  const {
    token: { colorBgContainer, borderRadiusLG },
  } = theme.useToken();

  return (
    <Layout style={{ height: '100vh' }}>
      <MenuSider />
      <Layout>
        <Header style={{ padding: 0, background: colorBgContainer }}>
          <Button
            type="text"
            icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
            onClick={() => setCollapsed(!collapsed)}
            style={{
              fontSize: '16px',
              width: 64,
              height: 64,
            }}
          />
        </Header>
        <Content
          style={{
            margin: '24px 16px 0',
            padding: 24,
            minHeight: 280,
            background: colorBgContainer,
            borderRadius: borderRadiusLG,
          }}
        >
          <Suspense fallback={<span>loading</span>}>
            <AuthRoute>
              <Outlet />
            </AuthRoute>
          </Suspense>
        </Content>
        <Footer style={{ textAlign: 'center' }}>
          Ant Design React ©{new Date().getFullYear()} Created by bugscafe-al
        </Footer>
      </Layout>
    </Layout>
  );
};

export default HomePage;
